package com.ah.proj.util;

import java.sql.*;

public class BaseDao {
//	private static final String CLASS_NAME = "org.sqlite.JDBC";
//	private static final String DB_FILE = "E:\\AhWebProj\\";
//	private static final String URL = "jdbc:sqlite:" + DB_FILE + "SQLiteSpy_1.9.12\\AhWeb.db3";
//	private static final String USER_NAME = "";
//	private static final String USER_PWD = "";
	private static final String CLASS_NAME = "com.mysql.jdbc.Driver";
	private static final String URL = "jdbc:mysql://localhost:3306/testJSP?useUnicode=true&characterEncoding=UTF8";
	private static final String USER_NAME = "root";
	private static final String USER_PWD = "root";
	protected Connection conn = null;
	protected PreparedStatement psta = null;
	protected ResultSet rs = null;

	public void getConn() {
		try {
			Class.forName(CLASS_NAME);
			conn = DriverManager.getConnection(URL, USER_NAME, USER_PWD);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	protected void closeConn() {
		try {
			if (rs != null) {
				rs.close();
				rs = null;
			}
			if (psta != null) {
				psta.close();
				psta = null;
			}
			if (conn != null) {
				conn.close();
				conn = null;
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}
}
